/**
 * 全局类型定义
 */

// 语言文件类型
export interface LanguageData {
  [key: string]: string;
}

// 语言文件信息
export interface LanguageFile {
  language: string;
  code: string;
  data: LanguageData;
  fileName: string;
  translations?: Array<{ key: string; value: string }>;
}

// 上传文件信息
export interface UploadFile {
  file: File;
  name: string;
  size: number;
  type: string;
}

// 处理状态
export type ProcessStatus = 'idle' | 'uploading' | 'parsing' | 'generating' | 'completed' | 'error';

// 处理进度
export interface ProcessProgress {
  status: ProcessStatus;
  progress: number;
  message: string;
  error?: string;
}

// 冲突检测结果
export interface ConflictResult {
  type: 'duplicate' | 'missing' | 'format_error';
  key: string;
  languages: string[];
  message: string;
  severity: 'low' | 'medium' | 'high';
}

// 检测报告
export interface DetectionReport {
  totalKeys: number;
  totalLanguages: number;
  conflicts: ConflictResult[];
  summary: {
    duplicates: number;
    missing: number;
    formatErrors: number;
  };
}

// 生成的文件信息
export interface GeneratedFile {
  language: string;
  code: string;
  fileName: string;
  content: string;
  size: number;
}

// 应用状态
export interface AppState {
  // 上传状态
  uploadFile: UploadFile | null;
  isUploading: boolean;
  
  // 处理状态
  processProgress: ProcessProgress;
  
  // 语言数据
  languageFiles: LanguageFile[];
  
  // 检测结果
  detectionReport: DetectionReport | null;
  
  // 生成的文件
  generatedFiles: GeneratedFile[];
  
  // UI状态
  currentStep: number;
  isProcessing: boolean;
}

// 应用操作
export interface AppActions {
  // 文件上传
  setUploadFile: (file: UploadFile | null) => void;
  setIsUploading: (isUploading: boolean) => void;
  
  // 处理进度
  setProcessProgress: (progress: ProcessProgress) => void;
  
  // 语言数据
  setLanguageFiles: (files: LanguageFile[]) => void;
  updateLanguageFile: (languageCode: string, updatedData: Record<string, string>) => void;
  
  // 检测结果
  setDetectionReport: (report: DetectionReport | null) => void;
  
  // 生成的文件
  setGeneratedFiles: (files: GeneratedFile[]) => void;
  
  // UI状态
  setCurrentStep: (step: number) => void;
  setIsProcessing: (isProcessing: boolean) => void;
  
  // 重置状态
  resetApp: () => void;
}

// 组件Props类型
export interface BaseComponentProps {
  className?: string;
  children?: React.ReactNode;
}

// 上传组件Props
export interface UploadComponentProps extends BaseComponentProps {
  onFileSelect: (file: UploadFile) => void;
  isUploading: boolean;
  accept?: string;
  maxSize?: number;
}

// 进度组件Props
export interface ProgressComponentProps extends BaseComponentProps {
  progress: ProcessProgress;
}

// 结果组件Props
export interface ResultComponentProps extends BaseComponentProps {
  languageFiles: LanguageFile[];
  detectionReport: DetectionReport | null;
  generatedFiles: GeneratedFile[];
  onDownload: () => void;
  onReset: () => void;
}
